
package system.base;

import java.util.ArrayList;

import system.LoginContext;

import com.hitrust.gs.util.date.DateUtil;

import framework.core.DBConnection;
import framework.core.IHandler;
import framework.core.ILoginContext;
import framework.core.Logger;
import framework.core.SearchEvent;
import framework.core.SrvContext;


/*
	Author    :chengbiao.he
	CreateTime:2008-02-14 08:38:58
*/
public class ProductUpdatePriceSrv extends IHandler
{

	public ProductUpdatePriceSrv() 
	{
		super();
	}
	private void listProductUpdatePrice(DBConnection con,SrvContext context, ILoginContext loginContext,String path) throws Exception
	{
		String showType = context.getString("showType",null);
		
		ProductUpdatePriceSearchEvent event = (ProductUpdatePriceSearchEvent)SearchEvent.fromForm(context,ProductUpdatePriceSearchEvent.class);
		LoginContext tLoginContext = (LoginContext)loginContext;
		event.setCurrentWarehouseCode(tLoginContext.getLoginWarehouseCode());
		String isFirst=event.getIsFirst();
		
		if(showType==null||"".equals(showType)){
			showType=event.getShowtype();
		}
		
		if(isFirst==null||"".equals(isFirst)){
			event.setEnabledTimeStart(DateUtil.getCurrentDate("yyyy-MM-dd"));
		}
		
		if("0".equals(showType)){
			event.setAuditingStatus("1");
		}
		
		event.setShowType(showType);
		
		context.setSessionValue("ProductUpdatePriceSearchEvent",event);
		
		context.m_req.setAttribute("showType",showType);
		
		context.m_req.setAttribute("statusList",
				getAllStatus());
		
		context.m_req.setAttribute("auditingStatusList",
				getAllAuditingStatus());
		
		context.setNextUrl(path+"ProductUpdatePriceList.jsp");
	}

	public void doAction(DBConnection con,SrvContext context,ILoginContext loginContext) throws Exception
	{
		String action_code = context.getActionCode();
		String path = "/system/base/";
		
		if(action_code.equalsIgnoreCase("listProductUpdatePrice"))
		{
			listProductUpdatePrice(con,context,loginContext,path);
			return;
		}


		Logger.throwException("ProductUpdatePriceSrv","unknown action_code="+action_code);
	}


	 /**
     * 取得所有启用状态
     * 
     * @return
     */
    public ArrayList getAllStatus() {
    	ArrayList tResult = new ArrayList();
		String[] tArray = new String[2];
		tArray[0] = "0";
		tArray[1] = "否";
		tResult.add(tArray);
		tArray = new String[2];
		tArray[0] = "1";
		tArray[1] = "是";
		tResult.add(tArray);
        return tResult;
    }
    
    /**
     * 取得所有审批状态
     * 
     * @return
     */
    public ArrayList getAllAuditingStatus() {
    	ArrayList tResult = new ArrayList();
		String[] tArray = new String[2];
		tArray[0] = "0";
		tArray[1] = "待审批";
		tResult.add(tArray);
		tArray = new String[2];
		tArray[0] = "1";
		tArray[1] = "审批通过";
		tResult.add(tArray);
		tArray = new String[2];
        tArray[0] = "2";
        tArray[1] = "审批不通过";
		tResult.add(tArray);
        return tResult;
    }
}
